package problema004;

public class PalindormeProduct {
	
	public static void main(String[] args){
		System.out.println(largestPalindromicProduct());
	}
	
	public static int largestPalindromicProduct(){
		int mayor = 0, act;
		for(int j = 1; j < 1000; j++){
			for(int i = 1; i < 1000; i++){
				act = i * j;
				if(esPalindromo(act)){
					if(act > mayor) mayor = act;
				}
			}
		}
		return mayor;
	}

	
	public static boolean esPalindromo(int num){
		int reverso = 0, act = 0, orig = num;
		while (num > 0) {
		      act = num % 10;
		      reverso = reverso * 10 + act;
		      num = num / 10;
		 }
		return orig == reverso;
	}
}
